package utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import com.sxs.model.Menu;
import com.sxs.model.VaultNavigate;

/**
 * 登录获取权限
 * 
 * @author xuyang
 *
 */
public class LimitsOfAuthority {
	public static Logger logger = Logger.getLogger(LimitsOfAuthority.class);

	/**
	 * 拼接左侧列表直接返回到页面显示显示
	 * 
	 * @param list
	 *            左侧列表list实体类集合
	 * @return
	 */
	public static String getJointStr(List<Menu> list, HttpServletRequest request) {
		String returnStr = "<ul id='navigation'>";
		String mainurl = "";
		int lit = 0;
		for (int i = 0; i < list.size(); i++) {
			Menu ne = list.get(i);
			int fid = ne.getFid();
			if (i != 0 && fid == 0) {
				returnStr += "</ul></li>";
			}
			if (fid == 0) {
				if (i == 0) {
					returnStr += "<li><a class='head'>" + ne.getMenuName() + "</a><ul class='show'>";
				} else
					returnStr += "<li><a class='head'>" + ne.getMenuName() + "</a><ul>";
			} else {
				if (i == 1 && fid > 0 && lit == 0) {
					mainurl = request.getContextPath() + "" + ne.getFunctionParameters();
				}
				returnStr += "<li><a href='" + request.getContextPath() + "" + ne.getFunctionParameters() + "' target='main'>" + ne.getMenuName() + "</a></li>";
				lit++;
			}
		}
		returnStr += "</ul></li></ul><script type=\"text/javascript\">$('#main', parent.document).attr(\"src\",'"
				+ mainurl + "')</script>";
		return returnStr;
	}
}
